package com.spring.sd.trans;

import com.spring.sd.trans.dao.PersonMapper;
import com.spring.sd.trans.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class InsertPerson {
    @Autowired
    private PersonMapper personMapper;


    @Transactional(rollbackFor = Exception.class)
    public void test() {

        Person person = Person.builder().firstName("张2").lastName("三网2").city("上海").address("马当路999号").build();
        int insert = personMapper.insert(person);

        //int i = insert / 0;
        System.out.println(">>>>>>>>>> " + insert);

    }
}
